package com.cq.hd.app.controller;

import com.cq.hd.common.annotation.LoginUser;
import com.cq.hd.common.entity.AppLoginUser;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbAgentUnBindApplyApi;
import com.cq.hd.member.api.dto.*;
import com.cq.hd.member.api.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@Slf4j
@RestController
@RequestMapping("/agentUnBindApply")
@Api(tags = "经纪人解绑相关接口")
public class AgentUnBindApplyController {

    @Autowired
    private TbAgentUnBindApplyApi agentUnBindApplyApi;

    @ApiOperation(value = "经纪人申请解绑")
    @PostMapping("/apply")
    public Result<Boolean> apply(@ApiIgnore @LoginUser AppLoginUser appLoginUser,
                                 @RequestBody AgentUnBindApplyDto agentUnBindApplyDto) {
        agentUnBindApplyDto.setUserId(appLoginUser.getUserId());
        return agentUnBindApplyApi.apply(agentUnBindApplyDto);
    }

    @ApiOperation(value = "待审核解绑记录")
    @ApiResponse(response = AgentUnBindApplyPageVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/page")
    public Result<Page<AgentUnBindApplyPageVo>> page(@ApiIgnore @LoginUser AppLoginUser appLoginUser, AgentUnBindApplyPageDto agentUnBindApplyPageDto) {
        agentUnBindApplyPageDto.setInviterUserId(appLoginUser.getUserId());
        return agentUnBindApplyApi.page(agentUnBindApplyPageDto);
    }

    @ApiOperation(value = "审核经纪人解绑申请")
    @PostMapping("/audit")
    public Result<Boolean> audit(@ApiIgnore @LoginUser AppLoginUser appLoginUser,
                                 @RequestBody AgentUnBindApplyAuditDto auditDto) {
        auditDto.setInviterUserId(appLoginUser.getUserId());
        return agentUnBindApplyApi.audit(auditDto);
    }
}
